package top.cardone.beans;

import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import top.cardone.context.util.DateUtils;

import java.beans.PropertyEditorSupport;

/**
 * Created by Administrator on 2015/8/3.
 */
public class DateEditorSupport extends PropertyEditorSupport {
    @lombok.Setter
    private String[] parsePatterns;

    @Override
    public void setAsText(final String text) throws IllegalArgumentException {
        if (StringUtils.isBlank(text)) {
            return;
        }

        this.setValue(DateUtils.parseDate(text, this.parsePatterns));
    }
}